package com.daocheng.weblog.admin.controller;

import com.daocheng.weblog.admin.model.vo.categroy.AddCategoryReqVO;
import com.daocheng.weblog.admin.model.vo.categroy.DeleteCategoryReqVO;
import com.daocheng.weblog.admin.model.vo.categroy.FindCategoryPageListReqVO;
import com.daocheng.weblog.admin.service.AdminCategoryService;
import com.daocheng.weblog.common.aspect.ApiOperationLog;
import com.daocheng.weblog.common.utils.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName AdminCategoryController
 * @author: 稻城
 * @date: 2025/3/9
 * @Version 1.0
 * @description: TODO
 */
@RestController
@RequestMapping("/admin")
@Api(tags = "Admin 分类模块")
public class AdminCategoryController {
    @Autowired
    private AdminCategoryService adminCategoryService;

    @PostMapping("/category/add")
    @ApiOperation(value = "添加分类")
    @ApiOperationLog(description = "添加分类")
    public Response addCategory(@RequestBody @Validated AddCategoryReqVO addCategoryReqVO) {
        return adminCategoryService.addCategory(addCategoryReqVO);
    }


    @PostMapping("/category/list")
    @ApiOperation(value = "分页获取分类数据")
    @ApiOperationLog(description = "分页获取分类数据")
    public Response findCategoryList(@RequestBody @Validated FindCategoryPageListReqVO findCategoryPageListReqVO) {
        return adminCategoryService.findCategoryList(findCategoryPageListReqVO);
    }

    @PostMapping("/category/delete")
    @ApiOperation(value = "删除分类数据")
    @ApiOperationLog(description = "删除分类数据")
    public Response deleteCategory(@RequestBody @Validated DeleteCategoryReqVO deleteCategoryReqVO) {
        return adminCategoryService.deleteCategory(deleteCategoryReqVO);
    }
    @PostMapping("/category/select/list")
    @ApiOperation(value = "获取分类数据集合")
    @ApiOperationLog(description = "获取分类数据集合")
    public Response findCategorySelectList() {
        return adminCategoryService.findCategorySelectList();
    }
}
